fix(Wav2Vec2ForCTC): torch export#34023
Merged
gante merged 2 commits intohuggingface:mainfrom Oct 17, 2024
Merged
Conversation
Resolves the issue described in huggingface#34022 by implementing the masking of the hidden states using an elementwise multiplication rather than indexing with assignment. The torch.export functionality seems to mark the tensor as frozen even though the update is legal. This change is a workaround for now to allow the export of the model as a FxGraph. Further investigation is required to find the real solution in pytorch.
2f745d4 to
fc9d68b
Compare
ylacombe
approved these changes
Oct 10, 2024
Contributor
ylacombe
left a comment
There was a problem hiding this comment.
This LGTM, but I'd like another opinion for a torch compile expert as well!
Maybe @gante or @zucchini-nlp ? Thanks for your help
Member
|
Seems okey to me, compile stuff usually complain on in-place modification to tensor |
Contributor
|
Thanks @zucchini-nlp, requesting a core maintainer review then ! |
ylacombe
reviewed
Oct 14, 2024
Contributor
Author
|
@ylacombe @zucchini-nlp these errors seem unrelated to the slow tests. Is this expected? |
LysandreJik
approved these changes
Oct 15, 2024
Member
LysandreJik
left a comment
There was a problem hiding this comment.
Ok, thanks! @ylacombe feel free to merge once you're satisfied with the tests
Contributor
|
LGTM 👍 (I've rerun CI in case it was a transient error) |
This was referenced Oct 24, 2024
BernardZach
pushed a commit
to BernardZach/transformers
that referenced
this pull request
Dec 5, 2024
* fix(Wav2Vec2ForCTC): torch export Resolves the issue described in huggingface#34022 by implementing the masking of the hidden states using an elementwise multiplication rather than indexing with assignment. The torch.export functionality seems to mark the tensor as frozen even though the update is legal. This change is a workaround for now to allow the export of the model as a FxGraph. Further investigation is required to find the real solution in pytorch. * [run-slow] hubert, unispeech, unispeech_sat, wav2vec2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #34022 by implementing the masking of the hidden states using an elementwise multiplication rather than indexing with assignment.
The torch.export functionality seems to mark the tensor as frozen even though the update is legal.
This change is a workaround for now to allow the export of the model as a FxGraph. Further investigation is required to find the real solution in pytorch.
Tagging:
@ylacombe, @eustlb
Please let me know if someone else is more appropriate to review this PR.